//
//  YDStockMarketPopSelectedCell.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/1/22.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDStockMarketPopSelectedCell.h"
#import "YDHomeMarketModel.h"


@interface YDStockMarketPopSelectedCell()

//分割线
@property (nonatomic , weak) UIView *lineView;

//类别Label
@property (nonatomic , weak) UILabel *cateLabel;

@end


@implementation YDStockMarketPopSelectedCell


-(void)setModel:(YDHomeMarketModel *)model
{
    _model = model;
    
    self.cateLabel.text = model.name;
    
    if (model.isSelected) {
        self.cateLabel.textColor = [UIColor colorWithHexString:paleRed];
    }else{
        self.cateLabel.textColor = [UIColor colorWithHexString:dark];
    }
    
}


+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *stockMarketPopSelectedCell = @"YDStockMarketPopSelectedCell";
    YDStockMarketPopSelectedCell *cell = [tableView dequeueReusableCellWithIdentifier:stockMarketPopSelectedCell];
    if (cell == nil) {
        cell = [[YDStockMarketPopSelectedCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:stockMarketPopSelectedCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backgroundColor = [UIColor whiteColor];
        
        [self lineView];
        
        
        [self cateLabel];
        
    }
    return self;
}



-(UIView *)lineView
{
    if (_lineView == nil) {
        UIView *lineView = [[UIView alloc] init];
        [self.contentView addSubview:lineView];
        lineView.backgroundColor = NumberColor(247, 247, 247);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self);
            make.height.equalTo(@1);
            make.left.equalTo(self).offset(rate375(20));
            make.right.equalTo(self).offset(-rate375(20));
        }];
        _lineView = lineView;
    }
    return _lineView;
}

-(UILabel *)cateLabel
{
    if (_cateLabel == nil) {
        UILabel *cateLabel = [[UILabel alloc] init];
        [self.contentView addSubview:cateLabel];///104 114 132
        cateLabel.textColor = [UIColor colorWithHexString:dark];
        cateLabel.font = [UIFont systemFontOfSize:font16ScreenWRate * LKScreenW];
        cateLabel.textAlignment = NSTextAlignmentRight;
        cateLabel.text = @"";
        [cateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
        }];
        _cateLabel = cateLabel;
    }
    return _cateLabel;
}


@end
